<template id="coupon_workability">
	<div class="coupon_workability">

		<!--代金券-->

		<div class="coupon_cash">
         
         <dl class="coupon_first" v-for="(item,index) in coupon" :key="index">
         	<dt><img src="../../assets/images/coupon/coupon_03.png"/></dt>
         	<dd>
         		<div class="coupon_less">
         			<span>课程券</span>
         			<h6>全类品课程</h6>
         		</div>
         		<div class="coupon_sass">
         			<p>限APP客户端预约使用,瑜伽会所实体店预约无效</p>
         		</div>
         		<div class="coupon_data">
         			<span>有效期至:{{item.receive_time | formatDate}}</span>
         			<font @click.stop="jj">立即使用</font>
         		</div>
         	</dd>
         </dl>
         <div style="    text-align: center;
    padding-top: 100px;
    font-size: 13px;color:#8f8f94" v-if="seen">暂无优惠劵</div>
<!--         
           <dl class="coupon_second">
         	<dt><img src="../../assets/images/coupon/coupon_06.png"/></dt>
         	<dd>
         		<div class="coupon_less">
         			<span>课程券</span>
         			<h6>全类品课程</h6>
         		</div>
         		<div class="coupon_sass">
         			<p>限APP客户端预约使用,瑜伽会所实体店预约无效</p>
         		</div>
         		<div class="coupon_data">
         			<span>有效期至:2018-09-05</span>
         			<font>立即使用</font>
         		</div>
         	</dd>
         </dl>
         
         -->
         
         
		</div>

		<!--代金券结束-->

	</div>
</template>

<script>
	export default {
     data() {
            return{
				coupon:[],
				userid:'',
				coupon_money:'',
                seen:false
            }
       },
       created(){
       //	let SESSION_ID = JSON.parse(window.sessionStorage.getItem('SESSION_ID'));
		    var SESSION_ID=JSON.parse(window.localStorage.getItem('sessiond'))
       	let obj = {
				//请求的参数
				userid: SESSION_ID.user.id
			};
			var _this = this
			let qs = require('qs');
			this.$axios.post("/yujia/user/findValidCouponByUser", qs.stringify(obj), {
				headers: {
					'Content-Type': 'application/x-www-form-urlencoded'
				}
				//重写headers 请求头  qs.stringify(json对象) 把对象转化为字符串 
			}).then(function(response) {
				if(response.data.code =="0"){
					_this.seen=true
				}else if(response.data.code =='1'){
					_this.coupon = response.data.data
					_this.coupon_money = response.data.data[0].coupon_money
					
				}
				
			}).catch(function(error) {
				console.log(error);
			});
       },
       //将时间戳转换成日期格式
		filters: {
			formatDate: function(value) {
				let date = new Date(value);
				let y = date.getFullYear();
				let MM = date.getMonth() + 1;
				MM = MM < 10 ? ('0' + MM) : MM;
				let d = date.getDate();
				d = d < 10 ? ('0' + d) : d;
				
				return y + '-' + MM + '-' + d;
			}
		},
  methods:{
	Pay: function (index){
		this.pay = index
	},
	jj(){
		var coupon_money = this.coupon_money
		this.$router.push({
			path:'/',
			query:{
				
			}
				
		})
	}
	
		
	
  }
}
</script>

<style scoped>
	@import "../../assets/css/coupon_workability.css";
</style>